<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>run agents</title>

<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#cmd_test').click(function(){
		$.getJSON('http://127.0.0.1:8123/api.list', function(data){
			$('#div_sidebar').empty();
			var t_num = 0;
			var html = '<ul class="nav">';
			$.each(data, function(entryIndex, entry){
				//var t_urlstr = entry['urladr'] + ':' + entry['port'];
				//html += '<li id="li' + t_num + '"><a id="alist' + t_num + '" href="#" class="' + t_urlstr + '">' + entry['urladr'] + ':' + entry['port'] + '</a></li>';
				var t_urlstr = entryIndex;
				html += '<li id="li' + t_num + '"><a id="alist' + t_num + '" href="#" class="' + t_urlstr + '">' + entryIndex + '</a></li>';
				t_num += 1;
			});
			html += '</ul>';
			html += 'total agents:' + t_num + '<br>';
			html += 'url param:<input type="text" id="txt_param" name="txt_param">';
			html += '<input type="button" id="cmd_run" name="cmd_run" value="run" onclick="doruncase()">';
			$('#div_sidebar').append(html);
		});	
		
		return false;
	});

	$('#cmd_test').trigger('click');
});

function doruncase(){
	//alert($('#txt_param').attr('value'));
	var t_param = $('#txt_param').attr('value');
	if(t_param == "" || t_param == null){
		alert("the url param is empty or null!");
		return false;
	} 

	var t_url = '';
	$('a[id^=alist]').each(function(){
		t_url = 'http://' + $(this).attr('class') + '/' + t_param;
		$('.content').load(t_url);
		//alert(t_url);
	});	
}

</script>

<style type="text/css">
<!--
body {
	font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
	background: #42413C;
	margin: 0;
	padding: 0;
	color: #000;
}

ul, ol, dl { 
	padding: 0;
	margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
	margin-top: 0;	 
	padding-right: 15px;
	padding-left: 15px; 
}
a img { 
	border: none;
}

a:link {
	color: #42413C;
	text-decoration: underline; 
}
a:visited {
	color: #6E6C64;
	text-decoration: underline;
}
a:hover, a:active, a:focus { 
	text-decoration: none;
}

.container {
	width: 960px;
	background: #FFF;
	margin: 0 auto; 
	overflow: hidden; 
}

.sidebar1 {
	float: left;
	width: 180px;
	background: #EADCAE;
	padding-bottom: 10px;
}
.content {

	padding: 10px 0;
	width: 780px;
	float: left;
}

.content ul, .content ol { 
	padding: 0 15px 15px 40px; 
}

ul.nav {
	list-style: none; 
	border-top: 1px solid #666; 
	margin-bottom: 15px; 
}
ul.nav li {
	border-bottom: 1px solid #666; 
}
ul.nav a, ul.nav a:visited { 
	padding: 5px 5px 5px 15px;
	display: block; 
	width: 160px;  
	text-decoration: none;
	background: #C6D580;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus { 
	background: #ADB96E;
	color: #FFF;
}

.fltrt {  
	float: right;
	margin-left: 8px;
}
.fltlft { 
	float: left;
	margin-right: 8px;
}
.clearfloat { 
	clear:both;
	height:0;
	font-size: 1px;
	line-height: 0px;
}
-->
</style>
</head>

<body>

<div class="container">
  <div class="sidebar1" id="div_sidebar"></div>
    
  <div class="content">

    <!-- end .content --></div>
  <!-- end .container --></div>
</body>

<input type="hidden" name="cmd_test" id="cmd_test" value="test">
</html>
